package domain

import (
	"context"
	"errors"
	"github.com/zeromicro/go-zero/core/logx"
	"listenboos-common/db"
	"ucenter/dao"
	"ucenter/model"
	"ucenter/repo"
)

type UserPaidTrackDomain struct {
	userPaidTrackRepo repo.UserPaidTrackRepo
}

func (u *UserPaidTrackDomain) FindPaidTrack(ctx context.Context, albumId int64) (paidTracks []*model.UserPaidTrack, err error) {
	paidTracks, err = u.userPaidTrackRepo.FindPaidTrack(ctx, albumId)
	if err != nil {
		logx.Error(err)
		return nil, errors.New("数据库异常")
	}
	return paidTracks, err
}
func (u *UserPaidTrackDomain) FindPaidTrackByUserId(ctx context.Context, userId, trackId int64) (paidTracks []*model.UserPaidTrack, err error) {
	paidTracks, err = u.userPaidTrackRepo.FindPaidTrackByUserId(ctx, userId, trackId)
	if err != nil {
		logx.Error(err)
		return nil, errors.New("数据库异常")
	}
	return paidTracks, err
}
func NewUserPaidTrackDomain(db *db.ListenDB) *UserPaidTrackDomain {
	return &UserPaidTrackDomain{
		userPaidTrackRepo: dao.NewUserPaidTrackDao(db),
	}
}
